package com.itheima.controller;

import com.itheima.entity.Comment;
import com.itheima.service.ApiCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class ApiCommentController {
    @Autowired
    private ApiCommentService ApiCommentService;

    @GetMapping("/{id}")
    public Comment findComment(@PathVariable("id") Integer id){
        return ApiCommentService.findCommentById(id);
    }

    @GetMapping("/{id}/{content}")
    public void updateComment(@PathVariable("id") Integer id, @PathVariable("content") String content){
        ApiCommentService.updateComment(id, content);
    }

    @GetMapping("/delete/{id}")
    public void deleteComment(@PathVariable("id") Integer id) {
        ApiCommentService.deleteCommentById(id);
    }
}


